# -*- coding: utf-8 -*-
# @Time    : 2019-06-12 18:41
# @Author  : JackColor
# @File    : celery.py

from __future__ import absolute_import, unicode_literals
# from django.conf import settings
import os

from celery import Celery
from django.conf import settings

# 设置django环境
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jiangsqobj.settings')
app = Celery('jiangsqobj')
#  使用CELERY_ 作为前缀，在settings中写配置
app.config_from_object('django.conf:settings', namespace='CELERY')
# 发现任务文件每个app下的task.py
app.autodiscover_tasks()

# app.config_from_object('django.conf:settings')
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))  #dumps its own request information
